#include <iostream>
#include <windows.h>

// 定义导出函数类型
typedef const char* (*AICoder_GenerateCode_func)(const char*);
typedef const char* (*AICoder_GetPluginInfo_func)();
typedef bool (*AICoder_Initialize_func)();

int main() {
    std::cout << "🧪 测试 AICoder 插件..." << std::endl;
    
    HMODULE hDll = LoadLibrary("AICoder.dll");
    if (!hDll) {
        std::cout << "❌ 无法加载 AICoder.dll" << std::endl;
        return 1;
    }
    
    // 获取函数指针
    AICoder_Initialize_func initFunc = (AICoder_Initialize_func)GetProcAddress(hDll, "AICoder_Initialize");
    AICoder_GenerateCode_func genFunc = (AICoder_GenerateCode_func)GetProcAddress(hDll, "AICoder_GenerateCode");
    AICoder_GetPluginInfo_func infoFunc = (AICoder_GetPluginInfo_func)GetProcAddress(hDll, "AICoder_GetPluginInfo");
    
    if (!initFunc || !genFunc || !infoFunc) {
        std::cout << "❌ 无法获取插件函数" << std::endl;
        FreeLibrary(hDll);
        return 1;
    }
    
    std::cout << "✅ AICoder插件加载成功" << std::endl;
    std::cout << "插件信息: " << infoFunc() << std::endl;
    
    if (initFunc()) {
        std::cout << "✅ 插件初始化成功" << std::endl;
        
        // 测试代码生成
        const char* code = genFunc("创建一个Hello World程序");
        std::cout << "生成的代码:\n" << code << std::endl;
        
        std::cout << "🎉 插件测试完成！" << std::endl;
    } else {
        std::cout << "❌ 插件初始化失败" << std::endl;
    }
    
    FreeLibrary(hDll);
    return 0;
}
